package logic.common.game.endConditions;

import logic.common.game.Game;
import gameStates.GameTimeListener;

public class TimeOutCondition extends MatchEndCondition {
	
	protected boolean isEnding;
	
	public TimeOutCondition(final Game game) {
		super(game);
		
		game.getTeamA().getIngameState().addGameTimeListener(new GameTimeListener() {
			@Override
			public void gameTimeUpdate(Integer newGameTime) {
				if(newGameTime.intValue() <= 0 && !isEnding) {
					isEnding = true;
					endGame(game.getWinnerTeam());
				}
			}
			
			@Override
			public void respawnTimeUpdate() {}
			@Override
			public void endTimeUpdate(Integer newEndTime) {}
		});
	}
}